// -----------------------------------------------------------------------------
// M A R I T I M E   R E S E A R C H   I N S T I T U T E   N E T H E R L A N D S
// -----------------------------------------------------------------------------
// Copyright (C) November 27, 2009 MARIN - All rights reserved - http://www.marin.nl
// -----------------------------------------------------------------------------
// Program  : mermaid
// Module   : vbm
// File     : Array1DTest.cpp
// -----------------------------------------------------------------------------

#include <gtest/gtest_prod.h>
#include "Array1D.h"

const double TOLERANCE = 0.000001;

TEST(Array1D, default_constructor)
{
    Array1D<int> array;
    EXPECT_EQ(0, array.m_Size);
    EXPECT_EQ(0, array.m_pElements);
}

TEST(Array1D, size_constructor)
{
    Array1D<int> array(10);
    EXPECT_EQ(10, array.m_Size);
}

TEST(Array1D, copy_constructor)
{
    Array1D<int> array(10);
    array[0] = 20;
    array[9] = 30;
    Array1D<int> array2(array);
    EXPECT_EQ(10, array2.size());
    EXPECT_EQ(20, array2[0]);
    EXPECT_EQ(30, array2[9]);
}

TEST(Array1D, assignment_operator)
{
    Array1D<int> array(10);
    array[0] = 20;
    array[9] = 30;
    Array1D<int> array2;
    array2 = array;
    EXPECT_EQ(10, array2.size());
//    EXPECT_EQ(20, array2[0]);
//    EXPECT_EQ(30, array2[9]);
}

TEST(Array1D, value_assignment)
{
    Array1D<int> array(10);
    array = 20;
    EXPECT_EQ(20, array[3]);
}

TEST(Array1D, addition_operator)
{
    Array1D<int> array(10);
    array = 20;
    array += 10;
    EXPECT_EQ(30, array[3]);
}

TEST(Array1D, multiplication_operator)
{
    Array1D<int> array(10);
    array = 20;
    array *= 10;
    EXPECT_EQ(200, array[3]);
}

TEST(Array1D, equality_operator)
{
    Array1D<int> array(10);
    array = 10;
    Array1D<int> array2(array);
    EXPECT_EQ(true, array2 == array);
}

TEST(Array1D, inequality_operator)
{
    Array1D<int> array(10);
    array = 10;
    Array1D<int> array2;
    EXPECT_EQ(false, array2 == array);
}

TEST(Array1D, index_operator)
{
    // how do we test this?
}

TEST(Array1D, index_operator_readonly)
{
    // how do we test this?
}

TEST(Array1D, index_operator_alternative)
{
    // how do we test this?
}

TEST(Array1D, index_operator_alternative_readonly)
{
    // how do we test this?
}

TEST(Array1D, size)
{
    Array1D<int> array(10);
    ASSERT_EQ(10, array.size());
}

TEST(Array1D, dim)
{
    Array1D<int> array(10);
    ASSERT_EQ(10, array.dim());
}

TEST(Array1D, clear)
{
    Array1D<int> array(10);
    array = 10;
    array.clear();
    ASSERT_EQ(10, array.size());
    ASSERT_EQ(0, array[5]);
}

TEST(Array1D, resize)
{
    Array1D<int> array(10);
    ASSERT_EQ(10, array.size());
    array.resize(20);
    ASSERT_EQ(20, array.size());
}

TEST(Array1D, copy)
{
    Array1D<int> array(10);
    array = 10;
    Array1D<int> array2(10);
    array2 = 20;
    array2.copy(array);
    ASSERT_EQ(10, array[6]);
}

TEST(Array1D, prefixiterator)
{
    Array1D<int> array(10);
    for (int i = 0; i < 10; ++i)
    {
        array[i] = i;
    }
    int i = 0;
    for (Array1Diterator<int> it = array.begin(); it != array.end(); ++it)
    {
        ASSERT_EQ(i, *it); 
	++i;
    }
}

TEST(Array1D, postfixiterator)
{
    Array1D<int> array(10);
    for (int i = 0; i < 10; ++i)
    {
        array[i] = i;
    }
    int i = 0;
    for (Array1Diterator<int> it = array.begin(); it != array.end(); it++)
    {
        ASSERT_EQ(i, *it); 
	++i;
    }
}

